package com.ciwong.epaper.modules.epaper.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.me.adapter.BaseCommonAdapter;
import com.ciwong.epaper.modules.me.bean.CheckValidServiceBean;
import com.ciwong.epaper.util.EConstants;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by Administrator on 2017/8/21.
 */

public class MultipleServicesAdapter extends BaseCommonAdapter {
    public MultipleServicesAdapter(List<CheckValidServiceBean> dataList) {
        super(dataList);
    }

    @Override
    public int getItemResId(int position) {
        return R.layout.item_multiple_services;
    }

    @Override
    public Object createViewHolder(View convertView, int position) {
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.iv_service_logo = (ImageView) convertView.findViewById(R.id.iv_service_logo);
        viewHolder.tv_services_name = (TextView) convertView.findViewById(R.id.tv_service_name);
        return viewHolder;
    }

    @Override
    public void showData(Object bean, Object holder, int position) {
        CheckValidServiceBean checkValidServiceBean = (CheckValidServiceBean) bean;
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.tv_services_name.setText(checkValidServiceBean.name);
        try {
            ImageLoader.getInstance().displayImage(checkValidServiceBean.logo, viewHolder.iv_service_logo, EConstants.getDefAvatarCircleBuilder());
//            ImageLoader.getInstance().displayImage(checkValidServiceBean.logo, new ImageViewAware(viewHolder.iv_service_logo), EConstants.getBookCoverOption());
        } catch (OutOfMemoryError error) {

        }
    }


    private class ViewHolder {
        public ImageView iv_service_logo;
        public TextView tv_services_name;
    }
}
